Liferay: Converting 6.2 Portlets to 7.1 Part 1. The Overview.
Created: 4 June 2019 Modified:Converting portlets from 6.2 to 7.1 requires us to know where code and configurations belong in both versions. They are more similar than they are dissimilar. Knowing the differences and how to upgrade 6.2 portlets is key. I say we are “upgrading” rather than “converting” because that is how Liferay views it. You will be required to create upgrade code to modify 6.2 configuration data to 7.1 configuration data. We will be converting a portlet with a service layer.
Lets first look at the differences in the Maven modules between the versions.
Maven Modules
We are converting a 6.2 portlet with an associated service layer. Our JSPs, CSS, JS, HTML and MVCPortlet based class would be in the myApplication-portlet module. The code and configuration in myApplication-portlet module will be moved/converted into the AllFeed-Web module. One exception is the service.xml. Strangely, in 6.2, our entity/table definitions would be located in myApplication/myApplication-portlet/src/main/webapp/WEB-INF/service.xml. This is now more naturally located in modules/MyApplication-Service/MyApplication-Service-service/service.xml. The file that defines our entities is located in the service module.
Additionally all the generated code from ServiceBuilder that used to appear in myApplication-portlet and myApplication-portlet-service now appears in MyApplication-Service-api and MyApplication-Service-service. MyApplication-Service-api contains the public interfaces that are shared with other OSGI modules in Liferay. Via the OSGI framework you can use these interfaces to dependency inject MyApplicationService and MyApplicationLocalService into classes. You would do this using the @Reference annotation. MyApplication-Service-service contains the impl files that developers can customize. The same kind of impl files that used to be in myApplication-portlet in 6.2. Additionally the service.properties file has also moved to MyApplication-Service-service.
Service impl files in 6.2
Service Impl files in 7.1
Most (all?) of the information previously contained in the portlet.xml and liferay-portlet.xml are now annotations to the portlet class in 7.1. Let’s start by diving into Upgrading the Service.
tags: java - liferay - portlet - service builder